<?php
namespace Admin\Model;
use Think\Model;

/**
* Created by hanquan.
* User partner
* Date 2017/04/07
* Time 11:07
* CityModel 城市模型类
*/
class CityModel extends Model{
	
	private $City = null;
	function __construct(){
		$this->City = M('City');
	}

	/**
	 * get_city_lib 查询城市库列表
	 * @param int $pr_id 省份库id
	 * @return array 二维数组
	 */
	public function get_city_lib($pr_id){
		$condition['ci_province'] = $pr_id;
		return $this->City->table('city_lib')->where($condition)->select();
	}

	/**
	 * get_city 查询城市列表
	 * @param int $city_id 省份id
	 * @return array 一维数组
	 */
	public function get_city($pid){
		$condition['pid'] = $pid;
		return $this->City->where($condition)->select();
	}

	/**
	 * get_province_city 查询省份城市
	 * @param int $city_id 城市id
	 * @return array 一维数组
	 */
	public function get_province_city($city_id){
		$condition['city_id'] = $city_id;
		return $this->City->join('mp_province ON mp_city.pid = mp_province.pid')->where($condition)->find();
	}

	/**
	 * set_province 插入城市
	 * @param array $data 城市数据
	 */
	public function set_city($data){
		return $this->City->add($data);
	}
}